package com.nbsaas.boot.front.example;

import com.nbsaas.boot.example.api.apis.ExampleApi;
import com.nbsaas.boot.example.api.domain.request.ExampleRequest;
import com.nbsaas.boot.example.api.domain.request.ExampleSearch;
import com.nbsaas.boot.example.api.domain.response.ExampleResponse;
import com.nbsaas.boot.example.api.domain.simple.ExampleSimple;
import com.nbsaas.boot.rest.annotations.ViewOperator;
import com.nbsaas.boot.rest.response.ListResponse;
import com.nbsaas.boot.rest.response.PageResponse;
import com.nbsaas.boot.rest.response.ResponseObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 客户案例控制器
 */
@RestController
@RequestMapping("/front/example")
public class ExampleAction {


    @Resource
    private ExampleApi exampleApi;

    /**
     * 搜索数据
     *
     * @param request
     * @return
     */
    @PostMapping("/search")
    public PageResponse<ExampleSimple> search(@RequestBody ExampleSearch request) {
        return exampleApi.search(request);
    }

    /**
     * 列表数据
     *
     * @param request
     * @return
     */
    @PostMapping("/list")
    public ListResponse<ExampleSimple> list(@RequestBody ExampleSearch request) {
        return exampleApi.list(request);
    }


    /**
     * 查看数据
     *
     * @param request
     * @return
     */
    @PostMapping("/view")
    public ResponseObject<ExampleResponse> view(@RequestBody @Validated(ViewOperator.class) ExampleRequest request) {
        return exampleApi.view(request);
    }
}